package com.bjdd.jdy.ui.login;


import com.bjdd.jdy.base.BaseResult;
import com.bjdd.jdy.entity.TokenResult;
import com.bjdd.jdy.entity.User;
import com.bjdd.jdy.util.Api;
import com.bjdd.jdy.util.RxSchedulers;

import rx.Observable;

/**
 * Created by yukai on 2016/11/12.
 */

public class LoginModel implements LoginContract.Model {
    @Override
    public Observable<BaseResult<TokenResult>> getLoginModel(String account, String pwd, String timestamp, String sign) {
        return Api.getInstance().service
                .login(account,pwd,timestamp,sign)
                .compose(RxSchedulers.io_main());
    }

    @Override
    public Observable<BaseResult<User>> getUserInfo(String token, String userId) {
        return Api.getInstance().service
                .getUserInfo(token,userId)
                .compose(RxSchedulers.io_main());
    }

    @Override
    public Observable<BaseResult<String>> getCodeModel(String mobile, String timestamp, String sign) {
        return Api.getInstance().service
                .getLoginCode(mobile,timestamp,sign)
                .compose(RxSchedulers.io_main());
    }

    @Override
    public Observable<BaseResult<TokenResult>> codeLogin(String mobile, String timestamp, String code, String sign) {
        return Api.getInstance().service
                .codeLogin(mobile,timestamp,code,sign)
                .compose(RxSchedulers.io_main());
    }
}
